#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int start = a * 60;
	int end = c * 60;

	int spent_time = end - start;
	if (spent_time <= 0) spent_time += 1440;
	printf("%d %d", spent_time / 60, spent_time % 60);
	return 0;
}